package org.jiajie.designpatterndemo.visitor.lxf;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * @author jie
 * @date 2021/9/21 2:31 PM
 */
public class MyFileVisitor extends SimpleFileVisitor<Path> {
    // handle Directory:
    @Override
    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
        System.out.println("pre visit dir: " + dir);
        // 返回 CONTINUE 表示继续访问
        return FileVisitResult.CONTINUE;
    }
    // handle File:
    @Override
    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
        System.out.println("visit file:" + file);
        // 返回 CONTINUE 表示继续访问
        return FileVisitResult.CONTINUE;
    }
}
